package wms.service.user;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import wms.dao.user.OperatorMapper;
import wms.entity.Operator;

@Service
public class OperatorServiceImpl implements OperatorService {

	@Resource
	private OperatorMapper operatorMapper;
	
	@Override
	public Operator login(String loginCode, String passWord) throws Exception {
		Operator operator = operatorMapper.gerUserByLoginCode(loginCode);
		if (operator == null) 
			return null;
		return operator.getPassword().equals(passWord) == true ? operator : null;
	}

	@Override
	public boolean modifyOperator(Operator operator) throws Exception {
		if (operator == null) return false;
		operator.setLastLoginTime(new Date(System.currentTimeMillis()));
		return operatorMapper.txModify(operator);
	}

	@Override
	public int getTotalCount() throws Exception {
		return operatorMapper.getTotalCount();
	}

	
}
